#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    int n = 0;
    int m = 0;

    scanf("%d %d", &n, &m);
    int xx[n][m];
    int yy[n][m];
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            scanf("%d", &xx[i][j]);
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            scanf("%d", &yy[i][j]);
        }
    }

    double z = 0;
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (xx[i][j] == yy[i][j])
            {
                z++;
            }
            //printf("%d",yy[i][j]);
        }
    }

    double z1 = (double)(z / (n * m)) * 100;

    printf("%.2lf", z1);
    return 0;
}